﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProjetoJornada_Negocios.Fachada;
using Basicas;

namespace ProjetoJornada.Interno
{
    public partial class Jornada_Listar : System.Web.UI.Page
    {
        Fachada fachada = Fachada.Instance;

        protected void Page_Load(object sender, EventArgs e)
        {
            List<Jornada> jornadas = fachada.ConsultarTodasJornadas();
            jornadas.Sort();

            GridView_Jornadas.DataSource = jornadas;
            GridView_Jornadas.DataBind();            
        }

        protected void GridView_Jornadas_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            List<Jornada> jornadas = (List<Jornada>)GridView_Jornadas.DataSource;
            Jornada jornada = jornadas[e.RowIndex];
            fachada.RemoverJornada(jornada.Id);
            GridView_Jornadas.DataBind();

            Response.Redirect("Jornada_Listar.aspx");
        }
    }
}
